home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / matrix / rowcol_source.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-01  |  3.5 KB  |  135 lines

  1. /* matrix/rowcol_source.c
  2.  * 
  3.  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman, Brian Gough
  4.  * 
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or (at
  8.  * your option) any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful, but
  11.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. QUALIFIED_VIEW(_gsl_vector,view)
  21. FUNCTION (gsl_matrix, row) (QUALIFIED_TYPE(gsl_matrix) * m, const size_t i)
  22. {
  23.   QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW;
  24.   
  25.   if (i >= m->size1)
  26.     {
  27.       GSL_ERROR_VAL ("row index is out of range", GSL_EINVAL, view);
  28.     }
  29.   
  30.   {
  31.     TYPE(gsl_vector) v = NULL_VECTOR;
  32.     
  33.     v.data = m->data + i * MULTIPLICITY * m->tda;
  34.     v.size = m->size2;
  35.     v.stride = 1;
  36.     v.block = m->block;
  37.     v.owner = 0;
  38.     
  39.     ((VIEW(_gsl_vector, view) *)&view)->vector = v;
  40.     return view;
  41.   }
  42. }
  43.  
  44. QUALIFIED_VIEW(_gsl_vector,view)
  45. FUNCTION (gsl_matrix, column) (QUALIFIED_TYPE(gsl_matrix) * m, const size_t j)
  46. {
  47.   QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW;
  48.   
  49.   if (j >= m->size2)
  50.     {
  51.       GSL_ERROR_VAL ("column index is out of range", GSL_EINVAL, view);
  52.     }
  53.  
  54.   {
  55.     TYPE(gsl_vector) v = NULL_VECTOR;
  56.     
  57.     v.data = m->data + j * MULTIPLICITY;
  58.     v.size = m->size1;
  59.     v.stride = m->tda;
  60.     v.block = m->block;
  61.     v.owner = 0;
  62.  
  63.     ((VIEW(_gsl_vector, view) *)&view)->vector = v;
  64.     return view;
  65.   }
  66. }
  67.  
  68. QUALIFIED_VIEW(_gsl_vector,view)
  69. FUNCTION (gsl_matrix, diagonal) (QUALIFIED_TYPE(gsl_matrix) * m)
  70. {
  71.   QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW;
  72.  
  73.   TYPE(gsl_vector) v = NULL_VECTOR;
  74.   v.data = m->data;
  75.   v.size = GSL_MIN(m->size1,m->size2);
  76.   v.stride = m->tda + 1;
  77.   v.block = m->block;
  78.   v.owner = 0;
  79.  
  80.   ((VIEW(_gsl_vector, view) *)&view)->vector = v;
  81.   return view;
  82. }
  83.  
  84. QUALIFIED_VIEW(_gsl_vector,view)
  85. FUNCTION (gsl_matrix, subdiagonal) (QUALIFIED_TYPE(gsl_matrix) * m,
  86.                                     const size_t k)
  87. {
  88.   QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW;
  89.   
  90.   if (k >= m->size1)
  91.     {
  92.       GSL_ERROR_VAL ("subdiagonal index is out of range", GSL_EINVAL, view);
  93.     }
  94.  
  95.   {
  96.     TYPE(gsl_vector) v = NULL_VECTOR;
  97.     
  98.     v.data = m->data + k * MULTIPLICITY * m->tda;
  99.     v.size = GSL_MIN(m->size1 - k, m->size2);
  100.     v.stride = m->tda + 1;
  101.     v.block = m->block;
  102.     v.owner = 0;
  103.     
  104.     ((VIEW(_gsl_vector, view) *)&view)->vector = v;
  105.     return view;
  106.   }
  107. }
  108.  
  109. QUALIFIED_VIEW(_gsl_vector,view)
  110. FUNCTION (gsl_matrix, superdiagonal) (QUALIFIED_TYPE(gsl_matrix) * m,
  111.                                       const size_t k)
  112. {
  113.   QUALIFIED_VIEW(_gsl_vector,view) view = NULL_VECTOR_VIEW;
  114.  
  115.  
  116.   if (k >= m->size2)
  117.     {
  118.       GSL_ERROR_VAL ("column index is out of range", GSL_EINVAL, view);
  119.     }
  120.  
  121.   {
  122.     TYPE(gsl_vector) v = NULL_VECTOR;
  123.     
  124.     v.data = m->data + k * MULTIPLICITY;
  125.     v.size = GSL_MIN(m->size1, m->size2 - k);
  126.     v.stride = m->tda + 1;
  127.     v.block = m->block;
  128.     v.owner = 0;
  129.  
  130.     ((VIEW(_gsl_vector, view) *)&view)->vector = v;
  131.     return view;
  132.   }
  133. }
  134.  
  135.